<?php
/**
 * Created by PhpStorm.
 * User: bendyPRO
 * Date: 2018/3/15
 * Time: 23:22
 */

include("include/function.php");
include ("config/config.php");
$db_link=DB_Link();
$mongo = new \MongoDB\Driver\Manager();
$filter  = ['result' => "ok"];
$options = [];

$query = new \MongoDB\Driver\Query($filter, $options);
$rows   = $mongo->executeQuery('yunzhuanma.tasks', $query);

foreach ($rows as $d) {
    $sid=$d->_id;
    $md5=$d->md5;
    $name=$d->orgfile;
    $shareid=$d->shareid;
    $rpath=$d->rpath;
    $random=substr($rpath,-8);
    $today=substr($rpath,1,8);
    $time=$d->metadata->time;
    $size=$d->metadata->length;
    mysqli_query($db_link,"INSERT INTO `video_list` (`ID`, `filename`, `random`, `day`, `time`, `status`, `md5`, `sid`, `shareid`, `m_size`, `m_time`) VALUES (NULL, '".$name."', '".$random."', '".$today."', '".time()."', '2', '".$md5."', '".$sid."', '".$shareid."', $size, $time)");
    //echo "INSERT INTO `video_list` (`ID`, `filename`, `random`, `day`, `time`, `status`, `md5`, `sid`, `shareid`, `m_size`, `m_time`) VALUES (NULL, '".$name."', '".$random."', '".$today."', '".time()."', '2', '".$md5."', '".$sid."', '".$shareid."', $size, $time)";
}
